﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using Microsoft.Practices.ServiceLocation;
using TimeTravel.Controllers;
using TimeTravel.Extensions;
using TimeTravel.Extentions;

namespace TimeTravel.UnitTests
{
    public class TestBase
    {
        #region 准备工作
        /// <summary>
        /// 初始化服务
        /// </summary>
        static TestBase()
        {
            try
            {
                IWindsorContainer container = new WindsorContainer(new XmlInterpreter("Configuration\\Castle.config"));
                ControllerBuilder.Current.SetControllerFactory(new ChannelControllerFactory(container));
                ComponentRegister.AddComponentsTo(container);
                ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
            }
            catch (Exception e)
            {
                throw e;
            }
        } 
        #endregion
    }
}
